import Vue from 'vue'
import { initGlobalState } from 'qiankun';

let initialState = {};

// 初始化 state
const actions = initGlobalState(initialState);

actions.onGlobalStateChange((state, prev) => {
    // state: 变更后的状态; prev 变更前的状态
    console.log(state, prev);
    initialState = state
});

export function setGlobalState(state){
    actions.setGlobalState(state);
}
// actions.offGlobalStateChange();

Vue.prototype.shared = initialState

export default actions
